/******************************************************************************
* 文件名 	：bsp_math
* 作者	  ：菜菜的菠萝头
* 版本	  ：V1.0.0
* 日期	  ：2023/10.11
* 文件作用：常用算法
*
******************************************************************************
* 注意事项：
*1、注意使用方法。
*****************************************************************************/
#ifndef __BSP_MATH_H
#define __BSP_MATH_H

#include "fm33lg0xx_fl.h"

#define MathBspSprintf  sprintf

#define KEYWORD 1u	//如果报错，将关键词改成1u

#if KEYWORD

typedef signed long  s32;
typedef signed short s16;
typedef signed char  s8;

typedef unsigned long long  u64;
typedef unsigned long  u32;
typedef unsigned short u16;
typedef unsigned char  u8;

#endif

extern uint16_t MathBspUint8ArrayToHexString(const uint8_t *src, size_t srcLen, char *dest, size_t destSize);
extern uint16_t MathBspCrc16Calculate(const uint8_t *data, uint16_t length);
extern uint8_t MathBspStrCompareHex(uint8_t* data_in,uint8_t hex,uint16_t len);
extern uint8_t MathBspSumCheck(uint8_t* data,uint16_t len);
extern void MathBspStrCopy(uint8_t* data_out,const uint8_t* data_in,uint16_t len);
extern uint16_t MathBspStrCharLenth(uint8_t* data_in,uint16_t len);
extern void MathBspStrInit(uint8_t* data_out,const uint8_t data,uint16_t len);
extern uint16_t MathBspOneLineCharLenth(uint8_t* data_in,uint16_t len);
extern void MathBspBcdToHexU8(uint8_t* data_out,const uint8_t* data_in,uint16_t len);
extern void MathBspHexToBcdU8(uint8_t* data_out,const uint8_t* data_in,uint16_t len);

//和时间相关的算法
extern void MathBsp_timeCountToTime(uint32_t time_count, uint8_t time[7]);
extern bool MathBsp_validateTime(uint8_t time[7]);
extern uint32_t MathBsp_timeToTimeCount(uint8_t time[7]);


//数组处理相关算法
extern uint8_t MathBsp_CompareArrays(const uint8_t *arr1, const uint8_t *arr2, uint32_t length);

//延时函数
extern void MathBsp_Sofdelayms(uint32_t time);

#endif

